home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / misc / Audio.as next >
Encoding:
Text File  |  2011-10-17  |  2.7 KB  |  100 lines

  1. class classes.misc.Audio
  2. {
  3.    var which1;
  4.    var targetVol;
  5.    var fadeOutSecs;
  6.    var fadeInSecs;
  7.    var currentVol;
  8.    var level1FadeOut = false;
  9.    var level1FadeIn = false;
  10.    var c = 0;
  11.    var Name = "audio";
  12.    function Audio()
  13.    {
  14.    }
  15.    function playLevel5(pwhich, pvol)
  16.    {
  17.       var _loc2_ = pwhich;
  18.       var _loc3_ = pvol * 3;
  19.       _root.aC5.s5.stop();
  20.       _root.aC5.s5.attachSound(_loc2_);
  21.       _root.aC5.s5.setVolume(_loc3_);
  22.       _root.aC5.s5.start();
  23.    }
  24.    function playLevel4(pwhich, pvol)
  25.    {
  26.       var _loc2_ = pwhich;
  27.       var _loc3_ = pvol * 3;
  28.       _root.aC5.s5.stop();
  29.       _root.aC4.s4.stop();
  30.       _root.aC4.s4.attachSound(_loc2_);
  31.       _root.aC4.s4.setVolume(_loc3_);
  32.       _root.aC4.s4.start();
  33.    }
  34.    function playLevel3(pwhich, pvol)
  35.    {
  36.       var _loc2_ = pwhich;
  37.       var _loc3_ = pvol * 3;
  38.       _root.aC4.s4.stop();
  39.       _root.aC5.s5.stop();
  40.       _root.aC3.s3.stop();
  41.       _root.aC3.s3.attachSound(_loc2_);
  42.       _root.aC3.s3.setVolume(_loc3_);
  43.       _root.aC3.s3.start();
  44.    }
  45.    function playLevel2(pwhich, pvol)
  46.    {
  47.       var _loc2_ = pwhich;
  48.       var _loc3_ = pvol * 3;
  49.       _root.aC2.s2.stop();
  50.       _root.aC2.s2.attachSound(_loc2_);
  51.       _root.aC2.s2.setVolume(_loc3_);
  52.       _root.aC2.s2.start();
  53.    }
  54.    function playLevel1(pwhich, pvol, pfadeOutSecs, pfadeInSecs)
  55.    {
  56.       this.which1 = pwhich;
  57.       this.targetVol = pvol * 3;
  58.       this.fadeOutSecs = pfadeOutSecs;
  59.       this.fadeInSecs = pfadeInSecs;
  60.       this.currentVol = _root.aC1.s1.getVolume();
  61.       if(this.currentVol == 0)
  62.       {
  63.          this.currentVol = 1;
  64.       }
  65.       this.level1FadeOut = true;
  66.       this.c = 0;
  67.    }
  68.    function main()
  69.    {
  70.       if(this.level1FadeOut)
  71.       {
  72.          this.c = this.c + 1;
  73.          var _loc3_ = this.currentVol - this.c * (this.currentVol / (this.fadeOutSecs * 30));
  74.          _root.aC1.s1.setVolume(_loc3_);
  75.          if(_loc3_ < 0)
  76.          {
  77.             _root.aC1.s1.stop();
  78.             _root.aC1.s1.attachSound(this.which1);
  79.             _root.aC1.s1.setVolume(0);
  80.             var _loc4_ = !(this.which1 == "gammaThemeInstr" || this.which1 == "gammaThemeAcoustic") ? 999 : 0;
  81.             _root.aC1.s1.start(0,_loc4_);
  82.             this.level1FadeOut = false;
  83.             this.level1FadeIn = true;
  84.             this.c = 0;
  85.          }
  86.       }
  87.       if(this.level1FadeIn)
  88.       {
  89.          this.c = this.c + 1;
  90.          _loc3_ = this.c * (this.targetVol / (this.fadeInSecs * 30));
  91.          _root.aC1.s1.setVolume(_loc3_);
  92.          if(_loc3_ >= this.targetVol)
  93.          {
  94.             _root.aC1.s1.setVolume(this.targetVol);
  95.             this.level1FadeIn = false;
  96.          }
  97.       }
  98.    }
  99. }
  100.